<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
    <head>
        <th:block th:include="include :: header('修改知识库类别')"/>
        <link rel="stylesheet" type="text/css" th:href="@{/ajax/libs/qxEasyUI/themes/default/easyui.css}">
    </head>
    <style>
        .combo {
            border-color: #e5e6e7;
            border-radius: 4px;
        }
    </style>
    <body class="white-bg">
        <div class="wrapper wrapper-content animated fadeInRight ibox-content">
            <form class="form-horizontal m" id="form-replyTemplate-edit" style="margin-left: -20px;" th:object="${replyTemplate}">
                <input type="hidden" name="pkid" th:field="*{pkid}"/>
                <input type="hidden" name="deptId" th:field="*{deptId}"/>
                <input type="hidden" name="deptName" th:field="*{deptName}"/>
                <div class="form-group">
                    <label class="col-sm-3 control-label">回复模板内容：</label>
                    <div class="col-sm-8">
                        <textarea class="form-control" style="height: 200px;" name="replyContent" onkeydown="addTabOption(this)" th:field="*{replyContent}" required></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">显示排序：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="sort" th:field="*{sort}" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">回复类型：</label>
                    <div class="col-sm-5">
                        <select id="openflag" name="optType" class="form-control m-b">
                            <option value="1" th:selected="*{optType} == 1">电话回复模板</option>
                            <option value="2" th:selected="*{optType} == 2">信件回复模板</option>
                        </select>
                    </div>
                </div>
            </form>
        </div>
        <script th:src="@{/ajax/libs/layui/laydate.js}"></script>
        <th:block th:include="include :: footer"/>
        <script th:src="@{/ajax/libs/qxEasyUI/jquery.easyui.min.js}"></script>
        <script>
            var prefix = ctx + "system/replyTemplate";

            $("#form-replyTemplate-edit").validate({
                onkeyup: false,
                rules: {
                    replyContent: {
                        required: true,
                        minlength: 5
                    },
                    sort: {
                        required: true,
                        digits: true,
                        maxlength: 9
                    },
                },
                focusCleanup: true
            });

            function submitHandler() {
                var flag = $.validate.form();
                var replyContent = "reply"+$("[name='replyContent']").val();
                $("[name='replyContent']").val(replyContent)
                if(flag){
                    $.operate.save(prefix + "/rTempEdit", $('#form-replyTemplate-edit').serialize());
                }
            }

            function doSubmit(index, layero) {
                layer.close(index);
            }

            function addTabOption(opt){
                if(event.keyCode === 9){
                    opt.value = opt.value + "    "
                    // 阻止默认切换元素的行为
                    if (event && event.preventDefault) {
                        event.preventDefault()
                    } else {
                        window.event.returnValue = false
                    }
                }
            }
        </script>
    </body>
</html>
